package com.spider.test02;

import java.util.Scanner;

//分别输入年月日，判断这一天是这一年的第几天。
public class Demo1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Input year:");
        int year = sc.nextInt();
        System.out.print("Input month:");
        int month = sc.nextInt();
        System.out.print("Input day:");
        int day = sc.nextInt();
        int allday = calculateDay(year,month,day);
        System.out.println("This day is the " + allday + " day of this year.");

    }
    public static int calculateDay(int year,int month,int day){
        int months[]={31,28,31,30,31,30,31,31,30,31,30,31};
        if(year % 4 == 0 && year % 100 != 0 || year % 400 == 0){
            months[1] = 29;
        }
        int allday = day;
        for(int i = 0;i < month - 1;i++){
            allday += months[i];
        }
        return allday;
    }

}
